﻿namespace SolidMvvm {
	using System;

	public static class Check {
		public static void IsNotNull(object anyObject, string nameOfObject) {
			if (anyObject == null)
				throw new ArgumentNullException(nameOfObject, "Expected '" + nameOfObject + "' to be non-null.");
		}

		public static void IsNull(object anyObject, string nameOfObject) {
			if (anyObject != null)
				throw new ArgumentException(nameOfObject, "Expected '" + nameOfObject + "' to be null.");
		}

		//public static void IsWithinRange(int value, int minimum, int maximum, string nameOfObject)
		//{
		//    if (value < minimum || value > maximum)
		//        throw new ArgumentOutOfRangeException(nameOfObject, value, "Integer '" + nameOfObject + "' value " + value + " not within range " + minimum + " to " + maximum);
		//}

		//public static void IsWithinRange(double value, double minimum, double maximum, string nameOfObject)
		//{
		//    if (value < minimum || value > maximum)
		//        throw new ArgumentOutOfRangeException(nameOfObject, value, "Double '" + nameOfObject + "' value " + value + " not within range " + minimum + " to " + maximum);
		//}

		/// <summary>
		///     Throws an exception if the assertion is false.
		/// </summary>
		public static void IsTrue(bool isAssertionTrue, string descriptionOfExpectedConditionOrNull) {
			if (!isAssertionTrue)
				throw new ArgumentException(descriptionOfExpectedConditionOrNull == null ? "Assertion failed." : "Assertion failed: " + descriptionOfExpectedConditionOrNull);
		}
	}
}
